import Vue from "vue";
import Router from "vue-router";
import Layout from "@/views/layout";
Vue.use(Router);
const router = new Router({
  routes: [
    {
      path: "/",
      redirect: "/login",
    },
    {
      path: "/login",
      component: () => import("@/views/login"),
    },
    {
      path: "/layout",
      name: "layout",
      component: Layout,
      redirect: "/home",
      children: [
        {
          path: "/home",
          name: "home",
          component: () => import("@/views/home"),
        },
        // 信用业务-负责人激励
        {
          path: "/responsibleMotivation",
          name: "responsibleMotivation",
          component: () =>
            import("@/views/creditBusiness/ResponsibleMotivation"),
        },
        {
          path: "/dailyAverageLiabilities",
          name: "dailyAverageLiabilities",
          component: () =>
            import("@/views/creditBusiness/DailyAverageLiabilities"),
        },
        {
          path: "/customerFunds",
          name: "customerFunds",
          component: () => import("@/views/creditBusiness/CustomerFunds"),
        },
        {
          path: "/branchIncentives",
          name: "branchIncentives",
          component: () => import("@/views/creditBusiness/BranchIncentives"),
        },
        {
          path: "/warehouseCustomers",
          name: "warehouseCustomers",
          component: () => import("@/views/creditBusiness/WarehouseCustomers"),
        },
        {
          path: "/dept",
          name: "dept",
          component: () => import("@/views/basicInfo/Dept.vue"),
        },
      ],
    },

    { path: "*", component: () => import("@/views/login") },
  ],
});
// 路由守卫
router.beforeEach((to, from, next) => {
  if (to.name === from.name) {
    return;
  } else {
    next(); // 继续跳转
    console.log("next");
  }
});
export default router;
